local skel = fk.CreateSkill {
  name = "emo__gutong",
  tags = {Skill.Compulsory},
}

Fk:loadTranslationTable{
  ["emo__gutong"] = "孤痛",
  [":emo__gutong"] = "锁定技，①有“兄”标记的角色受到伤害后，你失去一点体力并增加一点体力上限。②当你不因此进入濒死状态时，若有“兄”标记的角色体力值大于0，你令其失去一点体力，然后若其存活，你回复一点体力并令其增加一点体力上限。",
}

skel:addEffect(fk.EnterDying, {
  anim_type = "negative",
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(skel.name) and target == player then
      local currentEvent = player.room.logic:getCurrentEvent()
      local hp_event = currentEvent:findParent(GameEvent.ChangeHp)
      if hp_event then
        local hp_data = hp_event.data
        if hp_data.who == player and hp_data.skillName == skel.name then
          return false
        end
      end
      local bro = player.room:getPlayerById(player:getMark("emo__weiyi_bro"))
      return bro and not bro.dead and bro.hp > 0
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local bro = room:getPlayerById(player:getMark("emo__weiyi_bro"))
    room:loseHp(bro, 1, skel.name)
    if bro.dead then return end
    if player:isWounded() and not player.dead then
      room:recover { num = 1, skillName = skel.name, who = player, recoverBy = player }
    end
    room:changeMaxHp(bro, 1)
  end,
})

skel:addEffect(fk.Damaged, {
  anim_type = "negative",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skel.name) and target.id == player:getMark("emo__weiyi_bro")
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:loseHp(player, 1, skel.name)
    room:changeMaxHp(player, 1)
  end,
})

return skel
